<%@ page contentType="text/html; charset=UTF-8"%>
<%@taglib uri="/struts-tags" prefix="s"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<script type="text/javascript" src="<%=basePath%>js/jquery-1.4.2.js"></script>
		<script type="text/javascript" src="<%=basePath%>js/validate/jquery.validate.js"></script>
		<script type="text/javascript" src="<%=basePath%>js/validate/messages_cn.js"></script>
		<script type="text/javascript"
			src="<%=basePath%>js/calendar/calendar.js"></script>
		<script type="text/javascript"
			src="<%=basePath%>js/calendar/calendar-setup.js"></script>
		<script type="text/javascript"
			src="<%=basePath%>js/calendar/lang/calendar-zh_CN.js"></script>
		<script type="text/javascript">
			$(function() {
				$("#keyWord").hide();
				$("#search").hide();
				$("#condition").change(function() {
					if ($(this).val() == "petName" || $(this).val() == "kind") {
						$("#keyWord").show();
						$("#search").show();
					} else {
						$("#keyWord").hide();
						$("#search").hide();
						$.post("petInfo!getPetInfo", {
							"type" : $(this).val()
						}, function(data) {
							window.location.href="index.jsp";
						})
					}
				});
				// 验证邮政编码
				jQuery.validator.addMethod("postCode_validate",function(value,element){
					return this.optional(element) || /^[0-9]{6}$/.test(value) ;
				},"非法邮政编码") ;

				// 验证手机号码
				jQuery.validator.addMethod("mobile_validate",function(value,element){
					return this.optional(element) || /^((\(\d{3}\))|(\d{3}\-))?13[0-9]\d{8}|15[89]\d{8}/.test(value) ;
				},"非法手机号码") ;

				// 验证下拉列表框
				jQuery.validator.addMethod("payChannel_validate",function(value,element){
					return this.optional(element) || value != "choice" ;
				},"必选字段") ;
				
				// 表单验证
				$("#checkoutForm").validate({
					rules:{
						"order.realName":{
							required:true,
							minlength:[3]
						},
						"order.address":{
							required:true
						},
						"order.postCode":{
							required:true,
							postCode_validate:true
						},
						"order.mobile":{
							required:true,
							mobile_validate:true
						},
						"order.orderDate":{
							required:true
						},
						"order.payChannel":{
							required:true,
							payChannel_validate:true
						},
						"order.carryChannel":{
							required:true,
							payChannel_validate:true
						}
					}
				});
			});
			
			// 验证文框 
			function searchByKeyWord() {
				if ($("#keyWord").val() == "") {
					alert("请输入关键字");
					return false;
				}
				return true;
			};
		</script>
	</head>
	<s:debug></s:debug>
	<body>
		<center>
			<h1>
				登陆页面
			</h1>
			<hr />
			<form action="login!login" method="post">
				用户名称:
				<input type="text" name="user.userName" />
				<br />
				用户密码:
				<input type="password" name="user.password" />
				<br />
				<input type="submit" value="登陆" />
				<input type="reset" value="重置" />
			</form>
			<hr />
			<a href="login!getAllUser">显示所有用户</a>
			<table border="1">
				<s:iterator value="userList" status="index">
					<tr>
						<td>
							用户名称:
							<s:property value="userName" />
						</td>
						<td>
							用户密码:
							<s:property value="password" />
						</td>
					</tr>
				</s:iterator>
			</table>
			<hr />
			总记录数: 共页

		</center>
		<script type="text/javascript">
	Calendar.setup( {
		inputField : "order.orderDate",
		ifFormat : "%Y-%m-%d",
		showsTime : "true",
		button : "orderTime",
		step : 1
	});
</script>
	</body>
</html>
